package com.zhuifeng.search.controller;

import com.zhuifeng.common.core.domain.R;
import com.zhuifeng.search.domain.Product;
import com.zhuifeng.search.domain.request.ProductRequest;
import com.zhuifeng.search.result.PageResult;
import com.zhuifeng.search.result.Result;
import com.zhuifeng.search.service.ProdoctService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/productSearch")
public class ProductSearch {
    private final ProdoctService prodoctService;

    public ProductSearch(ProdoctService prodoctService) {
        this.prodoctService = prodoctService;
    }

//    private final String INDEX_NAME = "product_info";


    //    private final RestHighLevelClient client;
//
//    public ProductSearch(RestHighLevelClient client) {
//        this.client  = new RestHighLevelClient(
//                RestClient.builder(
//                        new HttpHost("47.98.136.123", 9200, "http")));
//    }
    @PostMapping("/productInfoList")
    public Result<PageResult<Product>> productInfoList(@RequestBody ProductRequest productRequest) {
        Result<PageResult<Product>> list = prodoctService.productInfoList(productRequest);

        return list;

    }


}
